package cn.gp.chatclient.utils;

import java.util.HashMap;
import java.util.Map;
import java.util.function.Consumer;

public class EventBus {
    private static final Map<String, Consumer<Object>> subscribers = new HashMap<>();
    
    public static void subscribe(String eventType, Consumer<Object> handler) {
        subscribers.put(eventType, handler);
    }
    
    public static void publish(String eventType, Object data) {
        Consumer<Object> handler = subscribers.get(eventType);
        if (handler != null) {
            handler.accept(data);
        }
    }
}